﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式.MVC_模式
{
    public class MVCPatternDemo
    {
        public static void Test()
        {
            //从数据库获取学生记录
            Student model = RetrieveStudentFromDatabase();

            //创建一个视图：把学生详细信息输出到控制台
            StudentView view = new StudentView();

            StudentController controller = new StudentController(model, view);

            controller.UpdateView();

            //更新模型数据
            controller.SetStudentName("John");

            controller.UpdateView();
        }

        private static Student RetrieveStudentFromDatabase()
        {
            Student student = new Student();
            student.Name = ("Robert");
            student.RollNo = ("10");
            return student;
        }
    }
}
